
	<fieldset>
		<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>" name="envoyer_sms">
		<legend>Envoyer un sms</legend>
			<table>			
				<tr>
					<td><label>Message </label></td>
					<td><textarea cols="30" rows="7" name="message"></textarea></td>				
			</table>
			<input type="hidden" name="verifica_envio_envoyer_sms" value="1" />
			<input type="hidden" name="telephone" value="<?php echo $_GET["tel"]; ?>" >
			<input type="submit" id="button" name="envoyer_sms" value="Envoyer"/>		
		</form>
	</fieldset>  
	
	<?php
		if(array_key_exists("verifica_envio_envoyer_sms",$_POST)){
			$nowtime = date(" Y-m-d H:i:s");
			$telephone = $_POST['telephone'];				
			$telephone = str_replace(" ","",$telephone);
			$smsuser = "igushiken";		//Login du serveur
			$smspass = "updating123";			//mot de passe du serveur
			$sender = "+33622234466"; //mon tel :)
			$message= str_replace(" ","%20",$_POST['message']);
						if($telephone[0] == '0'){
					$telephone[0] = 3;
					$telephone = '+3'.$telephone;
			}
			elseif($telephone[1] == '3' || $telephone[0] == ' ' ){
					$telephone = '+'.$telephone;
			}
					
			
			$request='https://www.12voip.com/myaccount/sendsms.php?username='.$smsuser.'&password='.$smspass;
			$request=$request.'&from='.$sender.'&to='.$telephone.'&text='.$message;
			
			echo "<script type='text/javascript'>"; 
			echo "    window.open('$request','','width=10,height=10');"; 
			echo "</script>";
		
			file_get_contents($request);
			//curl($request);
			// echo '<a href='.$request.'>um teste</a>';
		
			$update="UPDATE reservation SET reservation_status='1',
											reservation_calltime = '$nowtime' 	
					
										WHERE reservation_clienttel = '$telephone' ";
		
			
			if($resultado = mysql_query($update,$conexao)) {
				echo "Sucess!\n";
			}
			else{
				echo "Erreur\n";					
			}
		}	
	?>